In [2]:
for i in ['a','b','c']:
try:
print i**2
except:
print "Not an integer"
In [3]:
x = 5
y = 0
try:
z = x/y
except:
print "x/y Division could not be performed"
finally:
print "All done!"
In [6]:
def ask():
while True:
try:
val = int(raw_input("Enter a number :"))
except:
print "Enter a proper number"
continue
else:
print "The square of the entered numer is :", val**2
break
In [7]:
ask()